package com.loveprogrammer.redismq.runner;

import com.alibaba.fastjson2.JSON;
import com.loveprogrammer.redismq.mq.MqUtil;
import com.loveprogrammer.redismq.mq.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName CommonRunner
 * @Description 启动执行工作
 * @Author admin
 * @Date 2023/10/16 10:28
 * @Version 1.0
 */
@Component
public class CommonRunner implements ApplicationRunner {

    @Autowired
    private MqUtil mqUtil;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        mqUtil.sendMessage("test","execute","key1","hello",2000L, TimeUnit.MILLISECONDS);
        mqUtil.sendMessage("test","execute2","key2","2",3000L, TimeUnit.MILLISECONDS);
        mqUtil.sendMessage("test2","execute","key3", JSON.toJSONString(new User("张三","20")),4000L, TimeUnit.MILLISECONDS);
        mqUtil.sendMessage("test2","execute2","key4","3.1415926",5000L, TimeUnit.MILLISECONDS);
    }
}
